package com.gdzn.netty.enums;


public enum DeviceMsgEnum {
    LOGIN(110,"登录"),
    ATTR_REPORT(310,"属性上报"),
    ALARM_REPOT(410,"告警上报"),
    PARAM(500,"远程控制请求");

    private int msgType;
    private String desc;

    DeviceMsgEnum(int msgType, String desc) {
        this.msgType = msgType;
        this.desc = desc;
    }

    public int getMsgType() {
        return msgType;
    }

    public void setMsgType(int msgType) {
        this.msgType = msgType;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    /**
     * 自己定义一个静态方法,通过code返回枚举常量对象
     * @param msgType
     * @return
     */
    public static DeviceMsgEnum getValue(int msgType) {
        for (DeviceMsgEnum deviceMsgEnum : values()) {
            if (deviceMsgEnum.getMsgType() == msgType) {
                return deviceMsgEnum;
            }
        }
        return null;
    }


}
